Skip to content

fix(correct): error on --min-corrected with empty input on the legacy paths - #919

Merged
nh13 merged 1 commit into
mainfrom
nh/fix-correct-min-corrected-empty
Sep 6, 2026
Merged

nh13 merged 1 commit into
mainfrom
nh/fix-correct-min-corrected-empty

Conversation

@nh13

@nh13 nh13 commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

What

The two legacy (non-chain) fgumi correct execution paths silently accepted --min-corrected on empty input. Both computed ratio_kept = records_written as f64 / total_records as f64 and gated if ratio_kept < min; on empty input total_records == 0, so ratio_kept is 0.0/0.0 = NaN, and NaN < min is always false — so --min-corrected did nothing. The chain path (check_min_corrected) and fgbio both error in this case, so the default (no---threads) path diverged from both.

Fix

  • Extract check_min_corrected into a single shared pub(crate) helper (in src/lib/commands/correct.rs) that treats total_records == 0 with a positive min as an explicit error, and have the chain module import and reuse it instead of keeping its own copy — one implementation, no divergent duplicates.
  • Both legacy sites (execute_single_thread_mode, and the currently-#[allow(dead_code)] execute_threads_mode, fixed for sibling parity) now call the shared helper and error on empty input, matching the chain path and fgbio.

The --metrics write ordering is deliberately unchanged: fgbio writes the metrics TSV before the --min-corrected assert (CorrectUmis.scala:152 — "a ratio below --min-corrected will cause a failure but all files will still be written"), and the legacy path already matches that.

Tests

  • test_min_corrected_empty_input_single_threaded_mode (rstest) and test_min_corrected_errors_on_empty_input_threads_mode — both legacy paths error on empty input + positive --min-corrected, and pass with non-empty/met input; verified red pre-fix.
  • test_min_corrected_empty_input_chain_mode (rstest) — the live --threads chain path errors on empty input end-to-end.

Full gate green (cargo ci-test 9960 passed / 31 skipped, plus fmt/lint/doc and --no-default-features/--all-features).

Relationship to the chain-only cutover

This is a live-bug fix on the default legacy path. A separate PR in this series retires the legacy correct path entirely (chain-only), which will delete this code — at which point the chain path (already correct) is the only path. Landing this first fixes the live bug immediately; if the cutover lands first, this can be closed as moot.

Risk: command output changes: none; unsafe changes: none, and CLAUDE.md needs no update; memory bounds, queue capacity, and thread/backpressure policy changes: none.

The shared check_min_corrected helper now rejects empty input when --min-corrected is positive across legacy and chain paths. Successful output and metrics ordering remain unchanged. Tests cover all execution paths.

… paths (parity with the chain/fgbio)

The two legacy (non-chain) correct code paths computed
ratio_kept = records_written / total_records and gated on
`ratio_kept < min`. On empty input total_records is 0, so this divided
0.0/0.0 to NaN, and `NaN < min` is always false -- silently passing
--min-corrected instead of erroring, while the chain path's
check_min_corrected (and fgbio) correctly error in this case.

Extract check_min_corrected as a shared pub(crate) helper (moved from
the chain module into commands::correct, which the chain module already
depends on) and route both legacy sites through it, so all three
correct paths share one implementation of the empty-input semantics
instead of three copies that can drift.
@nh13
nh13 deployed to github-actions September 4, 2026 21:03 — with GitHub Actions Active
@coderabbitai

coderabbitai Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Essentials

Run ID: 547c6b89-4762-4eae-9608-f35e31ecc9e3

📥 Commits

Reviewing files that changed from the base of the PR and between 247404b and 1795c58.

📒 Files selected for processing (2)
  • src/lib/commands/correct.rs
  • src/lib/pipeline/chains/commands/correct.rs

Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.


Walkthrough

The change centralizes --min-corrected validation in check_min_corrected. Positive minimums now fail explicitly when no records are processed. Tests cover single-threaded, legacy threaded, and live chain-based correction paths.

Changes

Minimum-corrected validation

Layer / File(s) Summary
Shared minimum-corrected validation
src/lib/commands/correct.rs, src/lib/pipeline/chains/commands/correct.rs
Correction paths use the shared check_min_corrected helper. Empty input rejects positive minimums, while zero minimums pass.
Correction-path regression coverage
src/lib/commands/correct.rs
Regression tests cover single-threaded, legacy threaded, and live chain-based execution for empty and non-empty inputs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 1795c

The command now reports an error when a positive minimum-corrected threshold is used with empty input, consistently across execution modes. The change is covered across the affected paths and is ready to merge.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title uses the required Conventional Commit format, names the affected correct command, and accurately describes the empty-input --min-corrected fix. The description is lowercase and has no en…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@nh13

nh13 commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai pause

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews paused.

@codecov

codecov Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.60%. Comparing base (247404b) to head (1795c58).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #919      +/-   ##
==========================================
+ Coverage   93.55%   93.60%   +0.04%     
==========================================
  Files         301      301              
  Lines      150626   150664      +38     
==========================================
+ Hits       140923   141022      +99     
+ Misses       9703     9642      -61     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nh13

nh13 commented Sep 6, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@nh13
nh13 added this pull request to the merge queue Sep 6, 2026
Merged via the queue into main with commit 7f3efe6 Sep 6, 2026
17 checks passed
@nh13
nh13 deleted the nh/fix-correct-min-corrected-empty branch September 6, 2026 17:32
@nh13 nh13 mentioned this pull request Sep 6, 2026

This branch was successfully deployed

1 active deployment
github-actions — 1795c58d Deployed Sep 4, 2026 by nh13 via coverage #4184
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant